﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain.Core.Specification;
using Domain.Entities;

namespace Domain.Service.Order
{
    /// <summary>
    /// 根据下单日期得到订单列表
    /// </summary>
    public class OrderFromDateSpecification : Specification<Order_Info>
    {
        DateTime? _fromDate;
        DateTime? _toDate;
        public OrderFromDateSpecification(DateTime? fromDate, DateTime? toDate)
        {
            _fromDate = fromDate ?? DateTime.MinValue;
            _toDate = toDate ?? DateTime.MaxValue;
        }
        public override global::System.Linq.Expressions.Expression<Func<Order_Info, bool>> SatisfiedBy()
        {
            Specification<Order_Info> spec = new TrueSpecification<Order_Info>();
            spec &= new DirectSpecification<Order_Info>(o => o.CreateDate >= _fromDate
                && o.CreateDate <= _toDate);
            return spec.SatisfiedBy();
        }
    }
}
